<template>
    <container type="top-header" :show="{header:formShow}" class="g-width100 g-height100" header-style="height:auto;" main-style="padding:0;">
        <Form slot="header" inline
              submit-bus-key="MpUserManageList"
              :form-items="formItems"
              label-width=""
        ></Form>
        <Table slot="main"
               ref="table"
               form-submit-bus-key="MpUserManageList"
               :columns="columns"
               :operations="tableOperations"
               unique-label="name"
               v-on:toolbarSearchClick="formShow = !formShow"
        ></Table>
    </container>
</template>

<script>
    import Container from '../../../../../common-util/src/components/page/Container.vue'
    import Form from '../../../../../common-util/src/components/page/Form.vue'
    import Table from '../../../../../common-util/src/components/page/Table.vue'

    export default {
        components:{
            Form,
            Table,
            Container
        },
        data(){
            return {
                formShow: true,
                formItems:[
                    {
                        field: {
                            name: 'appCode'
                        },
                        element:{
                            type: 'select',
                            select:{
                                url: this.$baseURL.wx + '/wx/mp/config/list',
                                optionProp:{
                                    value: 'appCode',
                                    label: 'appName'
                                }
                            },
                            label: '公众号',
                        }
                    },

                    {
                        field: {
                            name: 'nickname'
                        },
                        element:{
                            label: '微信昵称',
                        }
                    },
                    {
                        field: {
                            name: 'howFromDictId'
                        },
                        element:{
                            type: 'selectDict',
                            selectDict:{
                                groupCode: 'wx_mp_user_how_from'
                            },
                            label: '来源',
                        }
                    },
                    {
                        element:{
                            type: 'button',
                            button:[
                                {
                                    action: 'submit',
                                    requestMethod:'get',
                                    url: this.$baseURL.wx + '/wx/mpuser/listPage',
                                    label: '查询'
                                },
                                {
                                    action: 'reset',
                                    label: '重置'
                                }
                            ]
                        }
                    }
                ],
                columns:[
                    {
                        prop: 'avatar',
                        label:'头像',
                        formatType: 'image'
                    },
                    {
                        prop: 'appCode',
                        label:'公众号编码',
                        showInDetail: true
                    },
                    {
                        prop: 'appName',
                        label:'公众号名称'
                    },
                    {
                        prop: 'openId',
                        label:'openId',
                        tooltip: true
                    },
                    {
                        prop: 'unionId',
                        label:'unionId',
                        showInDetail: true
                    },
                    {
                        prop: 'nickname',
                        label:'微信昵称'
                    },
                    {
                        prop: 'gender',
                        label:'性别',
                        formatter: (row, column, cellValue)=>{
                            if (cellValue == 1) {
                                return '男'
                            }
                            if (cellValue == 2) {
                                return '女'
                            }
                            return '未知'
                        }
                    },
                    {
                        prop: 'cityName',
                        label:'城市名称'
                    },
                    {
                        prop: 'provinceName',
                        label:'省名称'
                    },
                    {
                        prop: 'countryName',
                        label:'国家',
                        showInDetail: true
                    },

                    {
                        prop: 'language',
                        label:'语言',
                        showInDetail: true
                    },
                    {
                        prop: 'longitude',
                        label:'经度',
                        showInDetail: true
                    },
                    {
                        prop: 'latitude',
                        label:'纬度',
                        showInDetail: true
                    },
                    {
                        prop: 'precisions',
                        label:'经纬度精度',
                        showInDetail: true
                    },
                    {
                        prop: 'lacationDesc',
                        label:'地理位置描述',
                        showInDetail: true
                    },
                    {
                        prop: 'isSubscribe',
                        label:'是否关注'
                    },
                    {
                        prop: 'howFromDictName',
                        label:'来源'
                    },
                    {
                        prop: 'createAtTxt',
                        label:'创建时间'
                    },
                ],
                tableOperations:[
                    {
                        action: 'detail',
                        disabledOnMissingSelect:true,
                        label:'详情'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url:'/mpUser/location/:id',
                        label: '位置信息'
                    },
                    {
                        action: 'delete',
                        url:this.$baseURL.wx + '/wx/mpuser/:id',
                        disabledOnMissingSelect:true,
                        label:'删除'
                    }
                ]
            }
        }
    }
</script>

<style scoped>

</style>